package org.feiye.studyday09;

import java.util.Scanner;

public class Ording {
	public static void main(String[] args) {
		// 吃货联盟订餐系统
		// 1、菜品信息
		String[] dishNames = { "红烧带鱼", "肉末茄子", "土豆牛腩" };
		double[] prices = { 38.0, 20.0, 22.0 };
		int[] praises = new int[3];
		// 2、保存订单信息
		String[] names = new String[10];// 姓名
		String[] disMegs = new String[10];// 菜品信息
		int[] orderNums = new int[10];// 份数
		int[] times = new int[10];// 送餐时间
		String[] addresses = new String[10];// 送餐地址
		int[] states = new int[10];// 订单状态：0 已预订，1 已完成
		double[] sumPrices = new double[10];// 总金额
		// 3、订单初始化
		// 1号订餐人
		names[0] = "孙悟空";
		disMegs[0] = dishNames[0];
		orderNums[0]=3;
		times[0] = 18;
		addresses[0] = "花果山";
		states[0] = 0;
		sumPrices[0] = 114;
		// 2号订餐人
		names[1] = "猪八戒";
		disMegs[1] = dishNames[2];
		orderNums[1] = 2;
		times[1] = 12;
		addresses[1] = "高老庄";
		states[1] = 1;
		sumPrices[1] = 40;
		// 功能菜单
		System.out.println("----------------欢迎进入吃货联盟-------------------");
		Scanner in = new Scanner(System.in);
		int choice = 0;
		while (true) {
			System.out.println("-----------------------------------------------------------------");
			System.out.println("1、我要订餐    2、查看餐袋    3、签收订单    4、删除订单    5、我要点赞    6、返回主菜单    0、退出系统");
			System.out.println("-----------------------------------------------------------------");
			System.out.println("请选择：");
			choice = in.nextInt();
			switch (choice) {
			case 1:{
				System.out.println("序号" + "\t" + "菜品名" + "\t" + "单价" + "\t" + "点赞数");
				for (int i = 0; i < dishNames.length; i++) {
					System.out.println((i + 1) + "\t" + dishNames[i] + "\t" + prices[i] + "\t" + praises[i]);
				}
				int ch = 0;
				while (true) {
					System.out.println("请点餐：");
					ch = in.nextInt();
					if (ch <= 1 && ch >= 3) {
						break;
					}
					System.out.println("顾客姓名：");
					String name = in.next();
					System.out.println("点餐数：");
					int number = in.nextInt();
					System.out.println("送餐时间：");
					int time = in.nextInt();
					System.out.println("送餐地址：");
					String address = in.next();
					for (int i = 0; i < names.length; i++) {
						if (names[i] == null) {
							names[i] = name;
							disMegs[i] = dishNames[ch - 1];
							orderNums[i] = number;
							times[i] = time;
							addresses[i] = address;
							double money = prices[ch - 1] * number;
							money = money >= 50 ? money : money + 5;
							sumPrices[i] = money;
							break;
						}
					}
				}
			}
				break;
			case 2:{
				System.out.println("餐袋信息：");
				System.out.println("序号\t订餐人\t所定餐品信息\t送餐时间\t送餐地址\t\t总金额\t状态");
				for (int i = 0; i < names.length; i++) {
					if (names[i] == null) {
						break;
					}
					System.out.println((i + 1) + "\t" + names[i] + "\t" + disMegs[i] + "\t\t" + times[i] + "\t"
							+ addresses[i] + "\t\t" + sumPrices[i] + "\t" + (states[i] == 1 ? "已完成" : "已预订"));
					}
				}
				break;
				}
			if (choice == 0) {
				break;
			}
		}
	}
}
